<div style="padding:20px 20px 10px 20px">
    <form id="workflow_add_form" method="post">
        <table cellpadding="5">
            <tr>
                <td>工作流名称/文号:</td>                
            </tr>
            <tr>
                <td><input class="easyui-validatebox textbox" name="flow_add_title" data-options="required:true" style="width:480px;height:40px;"></input></td>
            </tr>      
        </table>
    </form>	
    <div style="text-align:center;padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="submitForm()">新建并办理</a>
    </div>	
</div>
<script>
$(document).ready(function(){
	$("[name = 'flow_add_title']").val("新建工作（<?php echo date("Y-m-d H:i:s")?>）");	
});
function submitForm(){
	$('#workflow_add_form').form('submit', {
		url:'<?php echo base_url();?>workflow/flow_new',
		onSubmit: function(param){
			param.p1 = 'value1';//额外参数1
			param.p2 = 'value2';//额外参数2
		},
		success:function(data){
			var data = eval('(' + data + ')');  // change the JSON string to javascript object
			if (!data.success){
				alert(data.errorMsg);
			}else{
				$('#dialog_custom_box').dialog('close');  // close a window	
				
				var title = (strlen(data.title) >10)?SetString(data.title,10)+'..':data.title;//如果标题超过10个字符，则截取10个字符加..
				var wf_id = 'workflow_'+data.id; //拼接面板ID
				var wf_obj = $('#main-tab').find("#"+wf_id);//获取面板ID对象对象
				//alert(es_obj.length);
				
				if (wf_obj.length>0){ //如果存在
					var tab_index = wf_obj.parent().index();//检查该对象的父元素在其父元素中的索引
					$('#main-tab').tabs('select', tab_index); //选择该索引对应的面板
				} else {
					/**添加一个tab标签**/
					flow_transact(data.id,data.ps_id,title);
					/*
					$("#main-tab").tabs('add',{
						id: wf_id,
						title: '工作流：'+title,
						href: '<?php echo base_url();?>workflow/flow_transact/'+data.id+'/'+data.ps_id,
						tabWidth:'160',
						selected: true,
						closable:true,
						onLoad:function(){
							//为面板添加详细标题属性 
							var item1 = $('.tabs-selected').find("span:first");
							$('#main-tab').find(item1).attr("title",data.title);
							
							//刷新工作流列表
							$('#workflow_list').datagrid('reload');	
						}
					});
					*/
				}
			}
		}
	});
}
</script>

